<template>
  <div class="mod-config">
    <el-card class="box-card search-input" shadow="never">
      <el-form  label-width="120px"  size="mini" :model="dataForm" @keyup.enter.native="findPage()">
        <el-row  label-width="120px"  size="mini">
          <el-col :span="6">
            <el-form-item label="主播手机号：" prop="account">
              <el-input v-model="dataForm.account"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="商家名称：" prop="personInfo">
              <el-input v-model="dataForm.personInfo"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="主播姓名：" prop="name">
              <el-input v-model="dataForm.name"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="审核状态：" prop="auditStatus">
              <el-select v-model="dataForm.auditStatus" style="width: 100%">
                <el-option
                  v-for="item in auditAnchorStatus"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row  label-width="120px"  size="mini">
          <el-col :span="6">
            <el-form-item label="主播身份证：" prop="identityCode">
              <el-input v-model="dataForm.identityCode" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-col :span="24" style="text-align: center;">
          <el-form-item>
            <el-button  type="primary" @click="$refs.CyTable.query(dataForm)">查询</el-button>
            <el-button @click="reset('dataForm')">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-card>
    <cy-table
      url="/api/v1/broadcast/shopAuditAnchor"
      :max-height="500"
      :highlightCurrentRow="true"
      :operationWidth="250"
      :totalSize="totalSize"
      :columns="filterColumns"
      :showEditOperation="false"
      :showDeleteOperation="false"
      :showBatchDelete="false"
      :showCheckCustomOperation="true"
      showCheckCustomLabel="auditStatus"
      showCheckCustomLabelVal="0/0"
      customBtbLable="审核通过/审核不通过"
      :showSelection="false"
      @findPage="findPage"
      @handleBtbCustom="handleBtbCustom"
      ref="CyTable"
    >
    </cy-table>

  </div>
</template>
<script>
  import CyTable from "./component/CyTable";
  export default {
    components: {
      CyTable,
    },
    data() {
      return {
        loading: false,
        auditAnchorStatus: [{
          label: '全部'
        },{
          value: 1,
          label: '审核通过'
        },{
          value: 2,
          label: '审核不通过'
        }],
        dataForm: {
        },
        columns: [],
        filterColumns: [],
        pageRequest: { pageNum: 1, pageSize: 10 },
        totalSize: 0,
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
      }
    },
    mounted: function () {
      this.columns = [
        { prop: "id", label: "序号", minWidth: 120 },
        { prop: "shopInfos", label: "申请商家", minWidth: 120},
        { prop: "createTime", label: "申请时间", minWidth: 160 },
        { prop: "account", label: "主播手机号", minWidth: 120 },
        { prop: "name", label: "主播姓名", minWidth: 120},
        { prop: "identityCode", label: "身份证号码", minWidth: 160 , formatter: this.defaultVal},
        { prop: "handPhoto", label: "照片", minWidth: 120, formatter: this.defaultVal,showType:'image',imgSize:{width:60,height:60}},
        { prop: "auditStatus", label: "审核状态", minWidth: 120, formatter: this.auditAnchorOption},
        { prop: "updateTime", label: "审核时间", minWidth: 160 },

      ];
      let temp = [];
      this.columns.forEach(function(key, val) {
        temp.push(key);
      });
      this.filterColumns = temp;
    },
    methods: {
      auditAnchorOption(row, column, cellValue, index) {
        //审核状态 审核进行中 1 审核通过 2 审核不通过
        if (cellValue == 1) {
          return "审核通过";
        } else if (cellValue == 2) {
          return "审核不通过";
        }
        return "";
      },
      // 获取数据列表
      findPage() {
        this.$refs.CyTable.findPage(this.dataForm);
      },
      // 每页数
      sizeChangeHandle(val) {
        this.pageSize = val
        this.pageIndex = 1
        this.findPage()
      },
      //重置
      reset(formName) {
        this.dataForm={};
        this.$refs.CyTable.resetForm(this.dataForm);
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val
        this.findPage()
      },
      //自定义按钮
      handleBtbCustom:function(params){
        let auditStatus = 1;
        let account=params.row.account;
        let auditAnchor="确认通过审核吗？";
        if(params.index==1){
          auditStatus = 2;
          auditAnchor="确认不通过审核吗？";
        }
        this.$confirm(auditAnchor, "提示", {}).then(() => {
          this.loading=true;
          let id = params.row.id;
          let param = {"id": id, "auditStatus": auditStatus,"account":account};
          let this_ = this;
          this.utils.request.liveRequest({
            url: '/api/v1/broadcast/anchorInfo/auditAnchor',
            method: 'post',
            params: param
          }).then(result => {
            let data = result.data;
            if (data.data === 1) {
              this_.$refs.CyTable.findPage(this_.dataForm)
              this_.$forceUpdate();
            }
            this.loading=false;
          })
        });
      },
    }
  }
</script>
<style scoped lang="scss">

</style>
